package com.lucweb.action;


import com.lucweb.entity.Jctask;
import com.lucweb.entity.JctaskIndex;
import com.lucweb.entity.Question;
import com.lucweb.entity.TaskBean;
import com.lucweb.service.JctaskService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller("jctaskAction")
@Scope("prototype")
public class JctaskAction extends ActionSupport {

    @Resource
    private JctaskService jctaskService;

    //首页所有任务对象
    private List<JctaskIndex> alljcTask;



    //检测任务对象
    private List<Question> jctaskList;
    private JctaskIndex jctaskIndex;




    //报告交付对象
    private List<String>bgjfaaa;

    private String missionaddress;


    //报告交付方法
    public String bgjfs() {
        /*没去除空格之前*/
        System.out.println("asdfasdf"+this.getBgjfaaa());

        /*获取从前台穿过来的字符串(注：这里必须去除空格，因为传过来的每个值之间除了有逗号分隔符之外还都有空格，但是通过trim()的方式是去不掉空格的)*/
        //String fruitStr = this.getFruits().trim();

//        /*必须如是这般才能去掉空格*/
////        String bgjfStr = this.getBgjfaaa().replaceAll(" ", "");
//        System.out.println("去除空格之后的字符串:" + bgjfStr);
//
//
//        /*把字符串通过逗号分隔为一个字符串数组*/
//        String[] bgjfs = bgjfStr.split(",");
//        /*遍历所有的值,把它们存到一个集合中*/
//        List<String> myBgjfs = new ArrayList<String>();
//
//        for(int i=0; i<bgjfs.length; i++){
//
//            myBgjfs.add(bgjfs[i]);
//        }




        return "bgjfs";

    }

    //获取所有检测任务方法
    public String getAlljcTask() {
        alljcTask = jctaskService.getAlljcTask();

        ActionContext.getContext().put("alljcTask", alljcTask);

        System.out.print(alljcTask.get(1));
        return "toJctaskIndex";

    }

    //获取单个任务方法
    public String TaskDetail() {
        String[] paras = (String[]) ActionContext.getContext().getParameters().get("task_id");
        String  para = paras[0];

        jctaskList = (List<Question>) jctaskService.getTaskDetail(para);

        System.out.print(jctaskList.get(1));
        ActionContext.getContext().put("jctaskList", jctaskList);

        return "toJctaskDetail";

    }


    public List<String> getBgjfaaa() {
        return bgjfaaa;
    }

    public void setBgjfaaa(List<String> bgjfaaa) {
        this.bgjfaaa = bgjfaaa;
    }

    public void setJctaskList(List<Question> jctaskList) {
        this.jctaskList = jctaskList;
    }
    public void setJctaskIndex(JctaskIndex jctaskIndex) {
        this.jctaskIndex = jctaskIndex;
    }

    public void setAlljcTask(List<JctaskIndex> alljcTask) {
        this.alljcTask = alljcTask;
    }

    public void setMissionaddress(String missionaddress) {
        this.missionaddress = missionaddress;
    }

    public String getMissionaddress() {
        return missionaddress;
    }
}
